<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>CMSIS-RTOS RTX: RTX_Conf_CM.c Configuration File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="cmsis.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="stylsheetf" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 46px;">
  <td id="projectlogo"><img alt="Logo" src="CMSIS_Logo_Final.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">CMSIS-RTOS RTX
   &#160;<span id="projectnumber">Version 4.74</span>
   </div>
   <div id="projectbrief">CMSIS-RTOS RTX: Real-Time Operating System for Cortex-M processor-based devices</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<div id="CMSISnav" class="tabs1">
    <ul class="tablist">
      <li class="current"><a href="./index.html"><span>RTX</span></a></li>
    </ul>
</div>
<!-- Generated by Doxygen 1.8.2 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><a href="pages.html"><span>Usage&#160;and&#160;Description</span></a></li>
      <li><a href="modules.html"><span>Reference</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('_r_t_x__conf__c_m.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">RTX_Conf_CM.c Configuration File </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>The file RTX_Conf_CM.c is used to define the configuration parameters of CMSIS-RTOS RTX. This file should be part of every project that is using the CMSIS-RTOS RTX kernel.</p>
<pre class="fragment">/*----------------------------------------------------------------------------
 *      RL-ARM - RTX
 *----------------------------------------------------------------------------
 *      Name:    RTX_Conf_CM.C
 *      Purpose: Configuration of CMSIS RTX Kernel for Cortex-M
 *      Rev.:    V4.74
 *----------------------------------------------------------------------------
 *
 * Copyright (c) 1999-2009 KEIL, 2009-2013 ARM Germany GmbH
 * All rights reserved.
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *  - Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *  - Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *  - Neither the name of ARM  nor the names of its contributors may be used 
 *    to endorse or promote products derived from this software without 
 *    specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *---------------------------------------------------------------------------*/

#include "cmsis_os.h"


/*----------------------------------------------------------------------------
 *      RTX User configuration part BEGIN
 *---------------------------------------------------------------------------*/

//-------- &lt;&lt;&lt; Use Configuration Wizard in Context Menu &gt;&gt;&gt; -----------------
//
// &lt;h&gt;Thread Configuration
// =======================
//
//   &lt;o&gt;Number of concurrent running user threads &lt;1-250&gt;
//   &lt;i&gt; Defines max. number of user threads that will run at the same time.
//   &lt;i&gt; Default: 6
#ifndef OS_TASKCNT
 #define OS_TASKCNT     6
#endif

//   &lt;o&gt;Default Thread stack size [bytes] &lt;64-4096:8&gt;&lt;#/4&gt;
//   &lt;i&gt; Defines default stack size for threads with osThreadDef stacksz = 0
//   &lt;i&gt; Default: 200
#ifndef OS_STKSIZE
 #define OS_STKSIZE     50
#endif

//   &lt;o&gt;Main Thread stack size [bytes] &lt;64-32768:8&gt;&lt;#/4&gt;
//   &lt;i&gt; Defines stack size for main thread.
//   &lt;i&gt; Default: 200
#ifndef OS_MAINSTKSIZE
 #define OS_MAINSTKSIZE 50
#endif

//   &lt;o&gt;Number of threads with user-provided stack size &lt;0-250&gt;
//   &lt;i&gt; Defines the number of threads with user-provided stack size.
//   &lt;i&gt; Default: 0
#ifndef OS_PRIVCNT
 #define OS_PRIVCNT     0
#endif

//   &lt;o&gt;Total stack size [bytes] for threads with user-provided stack size &lt;0-1048576:8&gt;&lt;#/4&gt;
//   &lt;i&gt; Defines the combined stack size for threads with user-provided stack size.
//   &lt;i&gt; Default: 0
#ifndef OS_PRIVSTKSIZE
 #define OS_PRIVSTKSIZE 0
#endif

//   &lt;q&gt;Check for stack overflow
//   &lt;i&gt; Includes the stack checking code for stack overflow.
//   &lt;i&gt; Note that additional code reduces the Kernel performance.
#ifndef OS_STKCHECK
 #define OS_STKCHECK    1
#endif

//   &lt;o&gt;Processor mode for thread execution 
//     &lt;0=&gt; Unprivileged mode 
//     &lt;1=&gt; Privileged mode
//   &lt;i&gt; Default: Privileged mode
#ifndef OS_RUNPRIV
 #define OS_RUNPRIV     1
#endif

// &lt;/h&gt;

// &lt;h&gt;RTX Kernel Timer Tick Configuration
// ======================================
//   &lt;q&gt; Use Cortex-M SysTick timer as RTX Kernel Timer
//   &lt;i&gt; Cortex-M processors provide in most cases a SysTick timer that can be used as 
//   &lt;i&gt; as time-base for RTX.
#ifndef OS_SYSTICK
 #define OS_SYSTICK     1
#endif
//
//   &lt;o&gt;RTOS Kernel Timer input clock frequency [Hz] &lt;1-1000000000&gt;
//   &lt;i&gt; Defines the input frequency of the RTOS Kernel Timer.  
//   &lt;i&gt; When the Cortex-M SysTick timer is used, the input clock 
//   &lt;i&gt; is on most systems identical with the core clock.
#ifndef OS_CLOCK
 #define OS_CLOCK       12000000
#endif

//   &lt;o&gt;RTX Timer tick interval value [us] &lt;1-1000000&gt;
//   &lt;i&gt; The RTX Timer tick interval value is used to calculate timeout values.
//   &lt;i&gt; When the Cortex-M SysTick timer is enabled, the value also configures the SysTick timer.
//   &lt;i&gt; Default: 1000  (1ms)
#ifndef OS_TICK
 #define OS_TICK        1000
#endif

// &lt;/h&gt;

// &lt;h&gt;System Configuration
// =======================
//
// &lt;e&gt;Round-Robin Thread switching
// ===============================
//
// &lt;i&gt; Enables Round-Robin Thread switching.
#ifndef OS_ROBIN
 #define OS_ROBIN       1
#endif

//   &lt;o&gt;Round-Robin Timeout [ticks] &lt;1-1000&gt;
//   &lt;i&gt; Defines how long a thread will execute before a thread switch.
//   &lt;i&gt; Default: 5
#ifndef OS_ROBINTOUT
 #define OS_ROBINTOUT   5
#endif

// &lt;/e&gt;

// &lt;e&gt;User Timers
// ==============
//   &lt;i&gt; Enables user Timers
#ifndef OS_TIMERS
 #define OS_TIMERS      1
#endif

//   &lt;o&gt;Timer Thread Priority
//                        &lt;1=&gt; Low
//     &lt;2=&gt; Below Normal  &lt;3=&gt; Normal  &lt;4=&gt; Above Normal
//                        &lt;5=&gt; High
//                        &lt;6=&gt; Realtime (highest)
//   &lt;i&gt; Defines priority for Timer Thread
//   &lt;i&gt; Default: High
#ifndef OS_TIMERPRIO
 #define OS_TIMERPRIO   5
#endif

//   &lt;o&gt;Timer Thread stack size [bytes] &lt;64-4096:8&gt;&lt;#/4&gt;
//   &lt;i&gt; Defines stack size for Timer thread.
//   &lt;i&gt; Default: 200
#ifndef OS_TIMERSTKSZ
 #define OS_TIMERSTKSZ  50
#endif

//   &lt;o&gt;Timer Callback Queue size &lt;1-32&gt;
//   &lt;i&gt; Number of concurrent active timer callback functions.
//   &lt;i&gt; Default: 4
#ifndef OS_TIMERCBQS
 #define OS_TIMERCBQS   4
#endif

// &lt;/e&gt;

//   &lt;o&gt;ISR FIFO Queue size&lt;4=&gt;   4 entries  &lt;8=&gt;   8 entries
//                         &lt;12=&gt; 12 entries  &lt;16=&gt; 16 entries
//                         &lt;24=&gt; 24 entries  &lt;32=&gt; 32 entries
//                         &lt;48=&gt; 48 entries  &lt;64=&gt; 64 entries
//                         &lt;96=&gt; 96 entries
//   &lt;i&gt; ISR functions store requests to this buffer,
//   &lt;i&gt; when they are called from the interrupt handler.
//   &lt;i&gt; Default: 16 entries
#ifndef OS_FIFOSZ
 #define OS_FIFOSZ      16
#endif

// &lt;/h&gt;

//------------- &lt;&lt;&lt; end of configuration section &gt;&gt;&gt; -----------------------

// Standard library system mutexes
// ===============================
//  Define max. number system mutexes that are used to protect 
//  the arm standard runtime library. For microlib they are not used.
#ifndef OS_MUTEXCNT
 #define OS_MUTEXCNT    8
#endif

/*----------------------------------------------------------------------------
 *      RTX User configuration part END
 *---------------------------------------------------------------------------*/

#define OS_TRV          ((uint32_t)(((double)OS_CLOCK*(double)OS_TICK)/1E6)-1)


/*----------------------------------------------------------------------------
 *      Global Functions
 *---------------------------------------------------------------------------*/

/*--------------------------- os_idle_demon ---------------------------------*/

void os_idle_demon (void) {
  /* The idle demon is a system thread, running when no other thread is      */
  /* ready to run.                                                           */

  for (;;) {
    /* HERE: include optional user code to be executed when no thread runs.*/
  }
}

#if (OS_SYSTICK == 0)   // Functions for alternative timer as RTX kernel timer

/*--------------------------- os_tick_init ----------------------------------*/

// Initialize alternative hardware timer as RTX kernel timer
// Return: IRQ number of the alternative hardware timer
int os_tick_init (void) {
  return (-1);  /* Return IRQ number of timer (0..239) */
}

/*--------------------------- os_tick_val -----------------------------------*/

// Get alternative hardware timer current value (0 .. OS_TRV)
uint32_t os_tick_val (void) {
  return (0);
}

/*--------------------------- os_tick_ovf -----------------------------------*/

// Get alternative hardware timer overflow flag
// Return: 1 - overflow, 0 - no overflow
uint32_t os_tick_ovf (void) {
  return (0);
}

/*--------------------------- os_tick_irqack --------------------------------*/

// Acknowledge alternative hardware timer interrupt
void os_tick_irqack (void) {
  /* ... */
}

#endif   // (OS_SYSTICK == 0)

/*--------------------------- os_error --------------------------------------*/

/* OS Error Codes */
#define OS_ERROR_STACK_OVF      1
#define OS_ERROR_FIFO_OVF       2
#define OS_ERROR_MBX_OVF        3

extern osThreadId svcThreadGetId (void);

void os_error (uint32_t error_code) {
  /* This function is called when a runtime error is detected.  */
  /* Parameter 'error_code' holds the runtime error code.       */

  /* HERE: include optional code to be executed on runtime error. */
  switch (error_code) {
    case OS_ERROR_STACK_OVF:
      /* Stack overflow detected for the currently running task. */
      /* Thread can be identified by calling svcThreadGetId().   */
      break;
    case OS_ERROR_FIFO_OVF:
      /* ISR FIFO Queue buffer overflow detected. */
      break;
    case OS_ERROR_MBX_OVF:
      /* Mailbox overflow detected. */
      break;
  }
  for (;;);
}


/*----------------------------------------------------------------------------
 *      RTX Configuration Functions
 *---------------------------------------------------------------------------*/

#include "RTX_CM_lib.h"

/*----------------------------------------------------------------------------
 * end of file
 *---------------------------------------------------------------------------*/
</pre> </div></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="_configure.html">Configuration of CMSIS-RTOS RTX</a></li>
    <li class="footer">Generated on Mon Feb 24 2014 11:07:07 for CMSIS-RTOS RTX by ARM Ltd. All rights reserved.
	<!--
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.2 
	-->
	</li>
  </ul>
</div>
</body>
</html>
